package com.iti.jets.gpts.home;

// default package
// Generated Mar 22, 2014 9:41:00 PM by Hibernate Tools 3.4.0.CR1

import com.iti.jets.gpts.dao.AbstractDAO;
import com.iti.jets.gpts.pojo.Terminal;
import com.iti.jets.gpts.pojo.TranService;
import com.iti.jets.gpts.pojo.TranServiceType;
import java.util.ArrayList;
import java.util.List;
import org.hibernate.Criteria;
import org.hibernate.SessionFactory;
import org.hibernate.criterion.Order;
import org.hibernate.criterion.Restrictions;

/**
 * Home object for domain model class TranService.
 *
 * @see .TranService
 * @author Hibernate Tools
 */
public class TranServiceHome extends AbstractDAO<TranService> {

    public TranServiceHome(SessionFactory sessionFactory) {
        super(sessionFactory);
    }

       public List searchByName(String name) {

        Criteria criteria = session.createCriteria(TranService.class, "t")
                .add(Restrictions.like("t.name", name))
                .addOrder(Order.asc("t.name"));

        List result = criteria.list();

        if (result.size() > 0) {
            return result;
        } else {
            return null;
        }
    }

    public List searchByTerminal(Terminal startTerminal, Terminal finalTerminal) {

        Criteria criteria = session.createCriteria(TranService.class, "t")
                .add(Restrictions.eq("t.terminalByTerminal1", startTerminal))
                .add(Restrictions.eq("t.terminalByTerminal2", finalTerminal));

        List result = criteria.list();
        if (result.size() > 0) {

            return result;
        } else {

            return null;
        }
    }

    public List searchByServiceType(TranServiceType tst) {
        Criteria criteria = session.createCriteria(TranService.class, "t")
                .add(Restrictions.eq("t.tranServiceType", tst));
        List result = criteria.list();
        if (result.size() > 0) {
            return result;
        } else {
            return null;
        }
    }
}
